{include file="common/header"}

<!-- 编辑器 -->
<script charset="utf-8" src="/Public/library/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/Public/library/kindeditor/lang/zh-CN.js"></script>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                   <div class="ibox-title">
                        <h5>修改密码</h5>
                        <span class="label label-primary pull-right label-primary-cust">
                        </span> 
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="partner" enctype="multipart/form-data">
                            <input type="hidden" name="id" value="<?php echo $admin['id']; ?>">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">帐号：</label>
                                <div class="col-sm-8">
                                    <input disabled="disabled" name="username" value="<?php echo $admin['username']; ?>" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">角色：</label>
                                <div class="col-sm-8">
                                    <input disabled="disabled" value="<?php echo $admin['group_name']; ?>" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">原密码：</label>
                                <div class="col-sm-8">
                                    <input name="old_password" type="password" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">新密码：</label>
                                <div class="col-sm-8">
                                    <input name="password" type="password" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认密码：</label>
                                <div class="col-sm-8">
                                    <input name="confirm_password" type="password" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group form-group-bottom">
                                <div class="col-sm-2 col-sm-offset-3">
                                    <p class="btn btn-primary" onclick="submitAdd();">确定修改</p>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            
            </div>
           
        </div>
    </div>
</body>
{include file="common/footer"}
<script>
    //按钮样式
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
    
    var flag = false;
    function submitAdd(){
        if ($("input[name=password]").val() != $("input[name=confirm_password]").val()) {
            swal('两次密码不一致', "", "warning");
            return false;
        }
        if (flag) {
            return false;
        }
        flag = true;
        $.ajax({
            url: "/Admin/Auth/password_edit",
            data:$('#partner').serialize(),
            type: "POST",
            dataType:'json',
            success: function (d) {
                if(d){
                    flag = false;
                    if(d.error){
                        swal(d.msg, "", "error");
                        return false;
                    }else{
                        swal(d.msg, "", "success");
                        setTimeout("window.location.href='/admin/Login/logout'",3000);
                        //setTimeout("window.location.reload()",1000);
                    }
                }
            }
        })

    }
</script>
